def fyrstaLausn(stodum, uppl):
	maxi = 0
	for x in stodum:
		if maxi < min(int(x), int(uppl[0])-int(x)):
			maxi = min(int(x), int(uppl[0])-int(x))
	return maxi

def onnurLausn(stodum, uppl):
	maxi = 0
	for x in stodum:
		if maxi < max(int(x), int(uppl[0])-int(x)):
			maxi = max(int(x), int(uppl[0])-int(x))
	return maxi

oft = int(input())
for x in range(oft):
	ln = input()
	lni = ln.split(" ")
	stadir = input()
	stadiri = stadir.split(" ")
	print(fyrstaLausn(stadiri, lni), end = ' ')
	print(onnurLausn(stadiri, lni))
	
